package gui;

import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;

import com.sun.java.swing.plaf.windows.WindowsBorders.DashedBorder;

public class PeriodeUI extends JPanel {
	private int idPeriode;
	private JPopupMenu popup;
	private SemaineUI semaine;
	
	private AbstractPopupController popupController = new AbstractPopupController() {
		public JPopupMenu makePopup(int x, int y) {
			return popup;
		}
	};

	public PeriodeUI(SemaineUI semaine, int idPer, JPopupMenu popup) {
		this.semaine = semaine;
		idPeriode = idPer;
		this.popup = popup;
		this.setLayout(new GridLayout(1,0));
		this.setBorder(new DashedBorder(Color.GRAY));
		addMouseListener(popupController);
	}
	
	public PeriodeUI(SemaineUI semaine, SeanceUI cours, JPopupMenu popup) {
		this(semaine, cours.getPeriodeId(), popup);
		add(cours);
	}
	
	public void add(SeanceUI cours)
	{
		super.add(cours);
		//this.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.BLACK));
	}

	public SemaineUI getSemaine() {
		return semaine;
	}
}
